home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / beos / PPBeDevKit.ZIP / PLAYERPR.TAR / PlayerPRO / Source / Import-Export / APPL.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-26  |  14.8 KB  |  623 lines

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 5.0 - DRIVER SOURCE CODE -
  4. //
  5. //    Library Version 5.0
  6. //
  7. //    To use with MAD Library for Mac: Symantec, CodeWarrior and MPW
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //
  14. //    COPYRIGHT ANTOINE ROSSET 1996, 1997, 1998
  15. //
  16. //    Thank you for your interest in PlayerPRO !
  17. //
  18. //    FAX:                (+41 22) 346 11 97
  19. //    PHONE:             (+41 79) 203 74 62
  20. //    Internet:     RossetAntoine@bluewin.ch
  21. //
  22. /********************                        ***********************/
  23.  
  24. #include "MOD.h"
  25. #include "MAD.h"
  26. #include "RDriver.h"
  27.  
  28. #if defined(powerc) || defined(__powerc)
  29. enum {
  30.         PlayerPROPlug = kCStackBased
  31.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  32.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof( OSType)))
  33.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof( Ptr)))
  34.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof( MADMusic*)))
  35.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof( PPInfoRec*)))
  36.         | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof( MADDriverSettings*)))
  37. };
  38.  
  39. ProcInfoType __procinfo = PlayerPROPlug;
  40. #else
  41. #include <A4Stuff.h>
  42. #endif
  43.  
  44.  
  45. Ptr MADPlugNewPtr( long size, MADDriverSettings* init)
  46. {
  47.     if( init->sysMemory) return NewPtrSys( size);
  48.     else return NewPtr( size);
  49. }
  50.  
  51. Ptr MADPlugNewPtrClear( long size, MADDriverSettings* init)
  52. {
  53.     if( init->sysMemory) return NewPtrSysClear( size);
  54.     else return NewPtrClear( size);
  55. }
  56.  
  57. void pStrcpy(register unsigned char *s1, register unsigned char *s2)
  58. {
  59.     register short len, i;
  60.     
  61.     len = *s2;
  62.     for ( i = 0; i <= len; i++) s1[ i] = s2[ i];
  63. }
  64.  
  65. OSErr MADResetInstrument( InstrData        *curIns)
  66. {
  67.     short i;
  68.  
  69.     for( i = 0; i < 32; i++) curIns->name[ i]    = 0;
  70.     curIns->type        = 0;
  71.     curIns->numSamples    = 0;
  72.     
  73.     ///
  74.     
  75.     for( i = 0; i < 96; i++) curIns->what[ i]        = 0;
  76.     for( i = 0; i < 12; i++)
  77.     {
  78.         curIns->volEnv[ i].pos        = 0;
  79.         curIns->volEnv[ i].val        = 0;
  80.     }
  81.     for( i = 0; i < 12; i++)
  82.     {
  83.         curIns->pannEnv[ i].pos    = 0;
  84.         curIns->pannEnv[ i].val    = 0;
  85.     }
  86.     curIns->volSize        = 0;
  87.     curIns->pannSize    = 0;
  88.     
  89.     curIns->volSus        = 0;
  90.     curIns->volBeg        = 0;
  91.     curIns->volEnd        = 0;
  92.     
  93.     curIns->pannSus        = 0;
  94.     curIns->pannBeg        = 0;
  95.     curIns->pannEnd        = 0;
  96.  
  97.     curIns->volType        = 0;
  98.     curIns->pannType    = 0;
  99.     
  100.     curIns->volFade        = DEFAULT_VOLFADE;
  101.     curIns->vibDepth    = 0;
  102.     curIns->vibRate        = 0;
  103.  
  104.     return noErr;
  105. }
  106.  
  107. void TurnRadio( short    item, DialogPtr    dlog, Boolean alors)
  108. {
  109. Handle        itemHandle;
  110. short        itemType;
  111. Rect        itemRect;
  112.  
  113. GetDialogItem (dlog, item, &itemType, &itemHandle, &itemRect);
  114.  
  115. if( alors) SetControlValue( (ControlHandle) itemHandle, 255);
  116. else SetControlValue( (ControlHandle) itemHandle, 0);
  117. }
  118.  
  119. void CopyResource( OSType type, short ID, short newID)
  120. {
  121. Handle    hRsrc;
  122.  
  123.     hRsrc = GetResource( type, ID);            DetachResource( hRsrc);
  124.     AddResource( hRsrc, type, newID, "\p");    WriteResource( hRsrc);
  125.     DetachResource( hRsrc);                    DisposeHandle( hRsrc);
  126. }
  127.  
  128. OSErr LoadMADH( Ptr MADPtr, MADMusic *MadFile, MADDriverSettings *init)
  129. {
  130. short                     i, maxInstru;
  131. long                     inOutCount, OffSetToSample;
  132. struct PatHeader        tempPatHeader;
  133. MADSpec                    *MadHeader;
  134.  
  135. /**** HEADER ****/
  136. MadFile->header = (MADSpec*) MADPlugNewPtr( sizeof( MADSpec), init);
  137. if( MadFile->header == 0L) return MADNeedMemory;
  138.  
  139. OffSetToSample = 0L;
  140. BlockMove( MADPtr, MadFile->header, sizeof( MADSpec));
  141. OffSetToSample += sizeof( MADSpec);
  142.  
  143. MadHeader = MadFile->header;
  144.  
  145. if( MadHeader->MAD != 'MADI') return MADFileNotSupportedByThisPlug;
  146.  
  147. //////////////////
  148.  
  149. MadFile->fid = ( InstrData*) MADPlugNewPtrClear( sizeof( InstrData) * (long) MAXINSTRU, init);
  150. if( !MadFile->fid) return MADNeedMemory;
  151.  
  152. MadFile->sample = ( sData**) MADPlugNewPtrClear( sizeof( sData*) * (long) MAXINSTRU * (long) MAXSAMPLE, init);
  153. if( !MadFile->sample) return MADNeedMemory;
  154.  
  155.  
  156. /**** PARTITION ****/
  157. for( i = MadHeader->numPat; i < MAXPATTERN; i++) MadFile->partition[ i] = 0L;
  158.  
  159. for( i = 0; i < MadHeader->numPat; i++)
  160. {
  161.     inOutCount = sizeof( PatHeader);
  162.     BlockMove( MADPtr + OffSetToSample, &tempPatHeader, inOutCount);
  163.     
  164.     inOutCount = sizeof( PatHeader) + MadHeader->numChn * tempPatHeader.size * sizeof( Cmd);
  165.     MadFile->partition[ i] = (PatData*) MADPlugNewPtr( inOutCount, init);
  166.     if( MadFile->partition[ i] == 0L) return MADNeedMemory;
  167.     
  168.     BlockMove( MADPtr + OffSetToSample, MadFile->partition[ i], inOutCount);
  169.     OffSetToSample += inOutCount;
  170. }
  171.  
  172. /**** INSTRUMENTS ****/
  173.  
  174. inOutCount = sizeof( InstrData) * (long) MadFile->header->numInstru;
  175. BlockMove( MADPtr + OffSetToSample, MadFile->fid, inOutCount);
  176. OffSetToSample += inOutCount;
  177.  
  178. for( i = MadFile->header->numInstru-1; i >= 0 ; i--)
  179. {
  180.     InstrData    *curIns = &MadFile->fid[ i];
  181.     
  182.     if( i != curIns->no)
  183.     {
  184.         MadFile->fid[ curIns->no] = *curIns;
  185.         MADResetInstrument( curIns);
  186.     }
  187. }
  188. MadFile->header->numInstru = MAXINSTRU;
  189.  
  190. for( i = 0; i < MAXINSTRU ; i++)
  191. {
  192.     short x;
  193.     
  194.     for( x = 0; x < MadFile->fid[ i].numSamples ; x++)
  195.     {
  196.         sData    *curData;
  197.     
  198.         // ** Read Sample header **
  199.         
  200.         curData = MadFile->sample[ i*MAXSAMPLE + x] = (sData*) MADPlugNewPtr( sizeof( sData), init);
  201.         if( curData == 0L) return MADNeedMemory;
  202.         
  203.         inOutCount = sizeof( sData);
  204.         
  205.         BlockMove( MADPtr + OffSetToSample, curData, inOutCount);
  206.         OffSetToSample += inOutCount;
  207.         
  208.         // ** Read Sample DATA
  209.         
  210.         inOutCount = curData->size;
  211.         
  212.         curData->data = MADPlugNewPtr( inOutCount, init);
  213.         if( curData->data == 0L) return MADNeedMemory;
  214.         
  215.         BlockMove( MADPtr + OffSetToSample, curData->data, inOutCount);
  216.         OffSetToSample += inOutCount;
  217.     }
  218. }
  219.  
  220. for( i = 0; i < MAXINSTRU; i++) MadFile->fid[ i].firstSample = i * MAXSAMPLE;
  221.  
  222. /*********************/
  223.  
  224. return( noErr);
  225. }
  226.  
  227. OSErr TESTMADH( MADSpec* MADPtr)
  228. {
  229.     if( MADPtr->MAD == 'MADI') return noErr;
  230.     else return MADFileNotSupportedByThisPlug;
  231. }
  232.  
  233. OSErr INFOMADF( MADSpec* MADPtr, PPInfoRec *info)
  234. {
  235. short    i;
  236.  
  237.     MADstrcpy( info->internalFileName, MADPtr->name);
  238.     
  239.     MADstrcpy( info->formatDescription, "MAD Resource (APPL)");
  240.     
  241.     info->totalPatterns        = MADPtr->numPat;
  242.     info->partitionLength    = MADPtr->numPointers;
  243.     
  244.     info->totalTracks        = MADPtr->numChn;
  245.     info->signature            = MADPtr->MAD;
  246.     
  247.     info->totalInstruments    = MADPtr->numInstru;
  248.     
  249.     return noErr;
  250. }
  251.  
  252.  
  253. short ChooseCompilation()
  254. {
  255. short        itemHit, result;
  256. DialogPtr    aDialog;
  257.  
  258.     aDialog = GetNewDialog( 173, 0L, (WindowPtr) -1L);
  259.     SetPort( aDialog);
  260.     
  261.     SetDialogDefaultItem( aDialog, 1);
  262.     
  263.     ShowWindow( aDialog);    
  264.  
  265.     TurnRadio( 6, aDialog, true);
  266.     result = 6;
  267.     
  268.     do
  269.     {
  270.         ModalDialog( 0L, &itemHit);
  271.         
  272.         switch( itemHit)
  273.         {
  274.             case 4:
  275.             case 5:
  276.             case 6:
  277.                 TurnRadio( result, aDialog, false);
  278.                 TurnRadio( itemHit, aDialog, true);
  279.                 result = itemHit;
  280.             break;
  281.         }
  282.     
  283.     }while( itemHit != 1 && itemHit != 2);
  284.     
  285.     DisposeDialog( aDialog);
  286.     
  287.     if( itemHit == 2) return -1;
  288.     
  289.     result -= 4;
  290.     return result;
  291. }
  292.  
  293.  
  294. OSErr SaveAPPL( short APPLType, short fRefNum, MADMusic *MadFile, MADDriverSettings *init)
  295. {
  296. OSErr                    iErr;
  297. short                    i, x;
  298. long                    fileSize, inOutCount, tt;
  299. Handle                    hRsrc;
  300.  
  301.  
  302.     // We need to compute number of valid instruments !!! See above....
  303.     
  304.     for( i = 0, x = 0; i < MAXINSTRU; i++)
  305.     {
  306.         MadFile->fid[ i].no = i;
  307.         
  308.         if( MadFile->fid[ i].numSamples > 0 || MadFile->fid[ i].name[ 0] != 0)    // Is there something in this instrument?
  309.         {
  310.             x++;
  311.         }
  312.     }
  313.     MadFile->header->numInstru = x;
  314.     
  315.     /////////////////////////////
  316.     
  317.     fileSize = sizeof( MADSpec);
  318.     fileSize += sizeof( InstrData) * MadFile->header->numInstru;
  319.     for( i = 0; i < MadFile->header->numPat; i++) fileSize += sizeof( PatHeader) + MadFile->header->numChn * MadFile->partition[ i]->header.size * sizeof( Cmd);
  320.     for( i = 0; i < MAXINSTRU ; i++)
  321.     {
  322.         for( x = 0; x < MadFile->fid[ i].numSamples ; x++)
  323.         {
  324.             sData    *curData = MadFile->sample[ i*MAXSAMPLE + x];
  325.             
  326.             fileSize += sizeof( sData);
  327.             fileSize += curData->size;
  328.         }
  329.     }
  330.     
  331.     if( init->sysMemory) hRsrc = NewHandleSys( fileSize);
  332.     else hRsrc =  NewHandle( fileSize);
  333.     if( hRsrc == 0L) return MADNeedMemory;
  334.     
  335.     tt = 0L;
  336.     HLock( hRsrc);
  337.     
  338.     /********* Write File *********/
  339.     inOutCount = sizeof( MADSpec);
  340.     BlockMove( MadFile->header, (*hRsrc) + tt, inOutCount);
  341.     tt += inOutCount;
  342.     
  343.     for( i = 0; i < MadFile->header->numPat ; i++)
  344.     {
  345.         MadFile->partition[ i]->header.compMode = 'NONE';
  346.         
  347.         inOutCount = sizeof(  PatHeader);
  348.         inOutCount += MadFile->header->numChn * MadFile->partition[ i]->header.size * sizeof( Cmd);
  349.         
  350.         BlockMove( MadFile->partition[ i], (*hRsrc) + tt, inOutCount);
  351.         tt += inOutCount;
  352.     }
  353.     
  354.     for( i = 0; i < MAXINSTRU ; i++)
  355.     {
  356.         if( MadFile->fid[ i].numSamples > 0 || MadFile->fid[ i].name[ 0] != 0)    // Is there something in this instrument?
  357.         {    
  358.             MadFile->fid[ i].no = i;
  359.             
  360.             inOutCount = sizeof( InstrData);
  361.             BlockMove( &MadFile->fid[ i], (*hRsrc) + tt, inOutCount);
  362.             tt += inOutCount;
  363.         }
  364.     }
  365.     
  366.     for( i = 0; i < MAXINSTRU ; i++)
  367.     {
  368.         for( x = 0; x < MadFile->fid[i].numSamples; x++)
  369.         {
  370.             sData    *curData = MadFile->sample[ i*MAXSAMPLE + x];
  371.             
  372.             inOutCount = sizeof( sData);
  373.             BlockMove( curData, (*hRsrc) + tt, inOutCount);
  374.             tt += inOutCount;
  375.             
  376.             inOutCount = curData->size;
  377.             BlockMove( curData->data, (*hRsrc) + tt, inOutCount);
  378.             tt += inOutCount;
  379.         }
  380.     }
  381.     /*******************************/
  382.     
  383.     MadFile->header->numInstru = MAXINSTRU;
  384.     
  385.     HUnlock( hRsrc);
  386.     
  387.     if( fileSize < tt) DebugStr("\pNeed more memory!");
  388.     
  389.     SetHandleSize( hRsrc, tt);
  390.     
  391.     AddResource( hRsrc, 'MADI', 3214, "\p");
  392.     WriteResource( hRsrc);
  393.     DetachResource( hRsrc);
  394.     DisposeHandle( hRsrc);
  395.     
  396.     /**** On copie les ressources nĂ„cessaires pour l'application **/
  397.  
  398.     if( APPLType == 0 || APPLType == 2)
  399.     {
  400.         CopyResource( 'CODE', 100, 0);
  401.         CopyResource( 'CODE', 101, 1);
  402.         CopyResource( 'DATA', 100, 0);
  403.     }
  404.     
  405.     CopyResource( 'BGGB', 128, 128);        // In PlayerPRO !!
  406.     CopyResource( 'ALRT', 3215, 3215);
  407.     CopyResource( 'DITL', 3214, 3214);
  408.     CopyResource( 'DLOG', 3214, 3214);
  409.     CopyResource( 'dctb', 3214, 3214);
  410.     CopyResource( 'Prou', 0, 0);
  411.     CopyResource( 'FREF', 228, 128);
  412.     CopyResource( 'FREF', 229, 129);
  413.     CopyResource( 'FREF', 230, 130);
  414.     CopyResource( 'BNDL', 228, 128);
  415.     CopyResource( 'WDEF', 200, 200);
  416.     CopyResource( 'PICT', 140, 140);
  417.     CopyResource( 'MENU', 128, 128);
  418.     CopyResource( 'MENU', 129, 129);
  419.     CopyResource( 'MENU', 131, 131);
  420.     CopyResource( 'MENU', 132, 132);
  421.     CopyResource( 'MENU', 133, 133);
  422.     CopyResource( 'MENU', 165, 165);
  423.     CopyResource( 'MENU', 169, 169);
  424.     CopyResource( 'MENU', 170, 170);
  425.     CopyResource( 'icl8', 228, 128);
  426.     CopyResource( 'ICN#', 228, 128);
  427.     CopyResource( 'ics#', 128, 128);
  428.     
  429.     hRsrc = GetResource( 'SIZE', 99);        DetachResource( hRsrc);
  430.     AddResource( hRsrc, 'SIZE', -1, "\p");
  431.     
  432.     fileSize = 300L * 1024L;
  433.     *((long*)((*hRsrc)+2)) = (long) fileSize;
  434.     *((long*)((*hRsrc)+6)) = (long) fileSize;
  435.     
  436.     WriteResource( hRsrc);                    DetachResource( hRsrc);        DisposeHandle( hRsrc);
  437.  
  438.     if( APPLType == 1 || APPLType == 2)
  439.     {
  440.         hRsrc = GetResource( 'XXXX', 128);        
  441.         inOutCount = GetResourceSizeOnDisk( hRsrc);
  442.         DetachResource( hRsrc);
  443.         HLock( hRsrc);
  444.         iErr = FSWrite(fRefNum, &inOutCount, *hRsrc);
  445.         HUnlock( hRsrc);
  446.         DisposeHandle( hRsrc);
  447.         
  448.         CopyResource( 'cfrg', 100, 0);
  449.     }
  450.     
  451.     return noErr;
  452. }
  453.  
  454. Boolean HasToClose( FSSpec *spec)
  455. {
  456.     CInfoPBRec    pb;                            // 108-byte area
  457.     HFileInfo    *fpb = (HFileInfo *)&pb;    // two pointer types
  458.     DirInfo        *dpb = (DirInfo *)&pb;
  459.     OSErr        rc;
  460.     
  461.     pb.hFileInfo.ioNamePtr         = spec->name;
  462.     pb.hFileInfo.ioVRefNum         = spec->vRefNum;
  463.     pb.hFileInfo.ioDirID         = spec->parID;
  464.     pb.hFileInfo.ioFDirIndex     = 0;
  465.     
  466.     rc = PBGetCatInfo( &pb, false);
  467.     if( rc != noErr) return false;
  468.     
  469.     if ( fpb->ioFlAttrib & 16)
  470.     {
  471.         return false;
  472.     }
  473.     else
  474.     {
  475.         if( fpb->ioFlAttrib & 4) return false;
  476.         else return true;
  477.     }
  478.     
  479.     return false;
  480. }
  481.  
  482. /*****************/
  483. /* MAIN FUNCTION */
  484. /*****************/
  485.  
  486. OSErr main( OSType order, Ptr AlienFileName, MADMusic *MadFile, PPInfoRec *info, MADDriverSettings *init)
  487. {
  488.     OSErr        myErr;
  489.     short        iFileRefI, i;
  490.     Handle        myRes;
  491.     Boolean        hasToClose;
  492.     FSSpec        AlienFileFSSpec;
  493.     
  494. #ifndef powerc
  495.     long    oldA4 = SetCurrentA4();             //this call is necessary for strings in 68k code resources
  496. #endif
  497.  
  498.     HGetVol( 0L, &AlienFileFSSpec.vRefNum, &AlienFileFSSpec.parID);
  499.     c2pstr( AlienFileName);
  500.     for( i = 0; i <= AlienFileName[ 0]; i++) AlienFileFSSpec.name[ i] = AlienFileName[ i];
  501.     
  502.     if( order != 'EXPL') hasToClose = HasToClose( &AlienFileFSSpec);
  503.     
  504.     myErr = noErr;
  505.     
  506.     switch( order)
  507.     {
  508.         case 'IMPL':
  509.             iFileRefI = FSpOpenResFile( &AlienFileFSSpec, fsRdPerm);
  510.             if( iFileRefI == -1) myErr = MADUnknowErr;
  511.             else
  512.             {
  513.                 UseResFile( iFileRefI);
  514.                 
  515.                 if( Count1Resources( 'MADI') > 0)
  516.                 {
  517.                     myRes = Get1IndResource( 'MADI', 1);
  518.                     DetachResource( myRes);
  519.                     HLock( myRes);
  520.                     
  521.                     myErr = LoadMADH( *myRes, MadFile, init);
  522.                     
  523.                     HUnlock( myRes);
  524.                     DisposeHandle( myRes);
  525.                 }
  526.                 else myErr = MADUnknowErr;
  527.                 
  528.                 if( hasToClose) CloseResFile( iFileRefI);
  529.             }
  530.         break;
  531.         
  532.         case 'TEST':
  533.             iFileRefI = FSpOpenResFile( &AlienFileFSSpec, fsRdWrPerm);    
  534.             if( iFileRefI == -1) myErr = MADUnknowErr;
  535.             else
  536.             {
  537.                 UseResFile( iFileRefI);
  538.                 
  539.                 if( Count1Resources( 'MADI') > 0)
  540.                 {
  541.                     myRes = Get1IndResource( 'MADI', 1);
  542.                     DetachResource( myRes);
  543.                     
  544.                     HLock( myRes);
  545.                     
  546.                     myErr = TESTMADH( (MADSpec*) *myRes);
  547.                     
  548.                     HUnlock( myRes);
  549.                     DisposeHandle( myRes);
  550.                 }
  551.                 else myErr = MADUnknowErr;
  552.                 
  553.                 if( hasToClose) CloseResFile( iFileRefI);
  554.             }
  555.         break;
  556.         
  557.         case 'EXPL':
  558.             {
  559.                 short    APPLType;
  560.                 short    fRefNum;
  561.                 
  562.                 APPLType = ChooseCompilation();
  563.                 if( APPLType == -1) break;
  564.                 
  565.                 FSDelete( AlienFileFSSpec.name, 0);
  566.                 Create( AlienFileFSSpec.name, 0, 'Prou', 'APPL');
  567.                 myErr = FSOpen( AlienFileFSSpec.name, 0, &fRefNum);
  568.                 if( myErr == noErr)
  569.                 {
  570.                     CreateResFile( AlienFileFSSpec.name);
  571.                     iFileRefI = FSpOpenResFile( &AlienFileFSSpec, fsRdWrPerm);
  572.                     if( iFileRefI == -1) myErr = MADUnknowErr;
  573.                     else
  574.                     {
  575.                         UseResFile( iFileRefI);
  576.                         
  577.                         myErr = SaveAPPL( APPLType, fRefNum, MadFile, init);
  578.                         
  579.                         CloseResFile( iFileRefI);
  580.                     }
  581.                     FSClose( fRefNum);
  582.                 }
  583.             }
  584.         break;
  585.  
  586.         case 'INFO':
  587.             iFileRefI = FSpOpenResFile( &AlienFileFSSpec, fsRdWrPerm);
  588.             if( iFileRefI == -1) myErr = MADUnknowErr;
  589.             else
  590.             {
  591.                 UseResFile( iFileRefI);
  592.                 
  593.                 if( Count1Resources( 'MADI') > 0)
  594.                 {
  595.                     myRes = Get1IndResource( 'MADI', 1);
  596.                     info->fileSize = GetResourceSizeOnDisk( myRes);
  597.                     
  598.                     DetachResource( myRes);
  599.                     HLock( myRes);
  600.                     
  601.                     myErr = INFOMADF( (MADSpec*) *myRes, info);
  602.                     
  603.                     HUnlock( myRes);
  604.                     DisposeHandle( myRes);
  605.                 }
  606.                 else myErr = MADUnknowErr;
  607.                 
  608.                 if( hasToClose) CloseResFile( iFileRefI);
  609.             }
  610.         break;
  611.         
  612.         default:
  613.             myErr = MADOrderNotImplemented;
  614.         break;
  615.     }
  616.     
  617.     p2cstr( (unsigned char*) AlienFileName);
  618.     
  619.     #ifndef powerc
  620.         SetA4( oldA4);
  621.     #endif
  622.     return myErr;
  623. }